import grails.util.GrailsUtil
class BootStrap {

    def init = { servletContext ->
		switch(GrailsUtil.environment){
			case "development":
				def admin = new seedswap.User(login:"admin",
					password:"wordpass",
					role:"admin")
					admin.save()
				if(admin.hasErrors()){
					println admin.errors
				}
				def jdoe = new seedswap.User(login:"jdoe",
					password:"password",
					role:"user")
					jdoe.save()
				if(jdoe.hasErrors()){
					println jdoe.errors
				}			
				def pine=new seedswap.Seed(
					name:"Pineapple",
					scientificName:"Pee",
					growingSeason:"GA",
					growingRegion:"SGA",
					cost:50.0,
					numSeeds:50,
					)
				pine.save()
				if(pine.hasErrors()){
					println pine.errors}
				def bob=new seedswap.Farmer(
					firstName:"Joe",
					lastName:"Doe",
					
					gender:"M",
					address:"1234",
					city:"Atlanta",
					state:"GA",
					zipcode:"32343",
					email:"email@me.com")
				bob.save()
				if(bob.hasErrors()){
					println bob.errors}
			break
		case "production":break}
    }
    def destroy = {
    }
}
